package uz.edo.app.admin.privilegePages;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import uz.edo.app.admin.AdminPage;
import uz.edo.db.bean.Privilege;
import uz.edo.db.manager.PrivilegeManager;

/**
 * Created by IntelliJ IDEA.
 * User: said
 * Date: 1/23/12
 * Time: 4:48 AM
 * To change this template use File | Settings | File Templates.
 */
public class PrivilegeEdit extends AdminPage{

    private PrivilegeManager manager = PrivilegeManager.getInstance();

    public PrivilegeEdit(final Privilege privilege) {
        CompoundPropertyModel model = new CompoundPropertyModel(privilege);
        Form form = new Form("form",model){
            @Override
            protected void onSubmit() {
                try {
                    manager.saveOrUpdate(privilege);
                    setResponsePage(PrivilegeListView.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        add(form);
        form.add(new TextField("name"));
    }
}
